package com.linran.javaweb.util;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;

@Slf4j
public class WebUtil {
    public static String readRequestBody(HttpServletRequest request) {
        try {
            StringBuilder builder = new StringBuilder();
            BufferedReader reader = request.getReader();
            String buffer;
            while ((buffer = reader.readLine()) != null) {
                builder.append(buffer);
            }
            return builder.toString();
        } catch (IOException e) {
            log.error(e.getMessage(), e);
        }
        return null;
    }
}
